`timescale 1ns / 1ps
// module name: tb_encoder
// author: yangtao2019
// date: 2021.07.11



module tb_encoder;
    //parameter n = ;
    //parameter N = (2<<n);


    // encoder0: N=32, n=5
    reg[31:0] paths0;
    wire[4:0] addr0;

    // encoder1: N=16, n=4
    reg[15:0] paths1;
    wire[3:0] addr1;
    
    // encoder2: N=8, n=3
    reg[7:0] paths2;
    wire[2:0] addr2;

    // encoder3: N=2, n=1
    reg[1:0] paths3;
    wire addr3;

    integer i;

    encoder#(.n(5)) encoder0 (.paths(paths0), .addr(addr0));
    encoder#(.n(4)) encoder1 (.paths(paths1), .addr(addr1));
    encoder#(.n(3)) encoder2 (.paths(paths2), .addr(addr2));
    encoder#(.n(1)) encoder3 (.paths(paths3), .addr(addr3));

    initial begin: unnamed
        #20
        {paths0, paths1, paths2, paths3} = 58'b0;
        #100
        {paths0, paths1, paths2, paths3} = {32'b1, 16'b1, 8'b1, 2'b1};

        // accumulate
        for (i=0;i<32;i=i+1) begin
            #100
            paths0 = {paths0[30:0], paths0[31]};
            paths1 = {paths1[14:0], paths1[15]};
            paths2 = {paths2[6:0], paths2[7]};
            paths3 = {paths3[0], paths3[1]};
        end
    end

endmodule

